import Taro, { Component } from '@tarojs/taro'
import { View, Button, Slot, Form } from '@tarojs/components'

import allRequest from './../../api/allRequest'

import './moreFormid.less'

class MoreFormid extends Component {

    componentWillReceiveProps(nextProps) {
        console.log(this.props, nextProps)
    }

    componentWillUnmount() { }

    componentDidShow() { }

    componentDidHide() { }

    getFormId(e) {
        if(!Taro.getStorageSync('hasWechatUser')){
            return
        }
        if(Taro.getEnv() === Taro.ENV_TYPE.WEB){
            return
        }else{
            if(e.detail.formId != 'the formId is a mock one'){
                allRequest.collectionFormid(e.detail.formId)
            }
        }
    }

    render() {
        return (
            // <View className='index'>
                <Form reportSubmit='true' onSubmit={this.getFormId.bind(this)} className='moreFormid'>
                    <Button form-type='submit'>
                        {this.props.children}
                    </Button>
                </Form>
            // </View>
        )
    }
}

export default MoreFormid
